import { SWFPlayer } from "../../scene/modle/SWFPlayer";
import { StaticResUrl } from "../../resource/StaticResUrl";
import { ModelType } from "../../scene/modle/data/ModelType";
import { ActionType } from "../../scene/modle/data/ActionType";
import { GuideArrowManager } from "../../manager/GuideArrowManager";
type int = number;
//class GuideArrow
    
    export  class GuideArrow /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.mouseChildren = false;
            this.mouseEnabled = false;
            return;
        }

        public updateDir(arg1: int): void
        {
            this.dispose();
            this._dir = arg1;
            if (!this._swfPlayer) 
            {
                this._swfPlayer = new SWFPlayer();
                this._swfPlayer.timeRate = 1;
            }
            addChild(this._swfPlayer);
            this._swfPlayer.loadComplete = this.onArrowLoaded;
            this._swfPlayer.load(StaticResUrl.GuideArrow, ModelType.NormalSwf, null);
            return;
        }

        /* internal  */onArrowLoaded(arg1: SWFPlayer): void
        {
            this._swfPlayer.updateFrame(ActionType.Stand, 1, true);
            this._swfPlayer.updateCurrentFrame(0);
            this._swfPlayer.play();
            this._swfPlayer.rotation = 0;
            var loc1=0;
            var loc2=0;
            var loc3=this._dir;
            switch (loc3) 
            {
                case GuideArrowManager.Dir_L:
                {
                    this._swfPlayer.rotation = 180;
                    loc1 = this._swfPlayer.width / 2;
                    break;
                }
                case GuideArrowManager.Dir_R:
                {
                    loc1 = (-this._swfPlayer.width) / 2;
                    break;
                }
                case GuideArrowManager.Dir_T:
                {
                    this._swfPlayer.rotation = -90;
                    loc2 = this._swfPlayer.height / 2;
                    break;
                }
                case GuideArrowManager.Dir_B:
                {
                    this._swfPlayer.rotation = 90;
                    loc2 = (-this._swfPlayer.height) / 2;
                    break;
                }
            }
            this._swfPlayer.x = loc1;
            this._swfPlayer.y = loc2;
            return;
        }

        public dispose(): void
        {
            this.baseX = 0;
            this.baseY = 0;
            this.baseLayer = null;
            if (this._swfPlayer) 
            {
                if (this._swfPlayer.parent == this) 
                {
                    removeChild(this._swfPlayer);
                }
                this._swfPlayer.dispose();
                this._swfPlayer.rotation = 0;
                this._swfPlayer.x = 0;
                this._swfPlayer.y = 0;
            }
            return;
        }

        /* internal */ /* var */_dir: int;

        /* internal */ /* var */_swfPlayer: SWFPlayer;

        public /* var */baseX: number=0;

        public /* var */baseY: number=0;

        public /* var */baseLayer: Object /* flash.display.DisplayObject */;
    }
